<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XS-blog登录页面</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_login.css">
</head>
<script src="js/jquery.min.js"></script>
<style>
    body{
        background-image: url("img/login.png");
    }
</style>
<script>
    $(function (){
       $("#submit").click(function (){
          var username=$("#username").val();
          var password=$("#password").val();
           if (username.trim() == "" || password.trim()==""){
               alert("用户名或密码不能为空！");
               window.location.href="blog_login.html";
               return;
           }

           $.ajax({
               url: "/user/loginMD",
               data:{"username":username,"password":password},
               type:"POST",
               dataType:"json",
               success:function (data){
                   console.log(data);
                   if (data.status==0){
                       alert("登录成功！");
                       window.location.href="blog_list.html";
                   }else {
                       alert("登录失败，用户名或者密码错误");
                       $("#username").val("");
                       $("#password").val("");
                       window.location.href="blog_login.html";
                   }
               }
           });
       });
    });


</script>
<body>

    <!-- 导航栏 -->
    <div class="nav">
        <img src="img/tom.jpeg" alt="">
        <span>XS-blog</span>
        <!-- 空白元素 实现占位 -->
        <div class="spacer"></div>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="register.html ">注册</a>
    </div>
    <div class="login-container">

            <div class="login-dialog">
                <h3>登录</h3>
                <div class="row">
                    <span>用户名</span>
                    <input type="text" id="username" name="username" value="admin">
                </div>
                <div class="row">
                    <span>密码</span>
                    <input type="password" id="password" name="password" value="admin">
                </div>
                <div class="row">
                    <!-- <button>提交</button> -->
                    <input type="submit" id="submit" value="提交">
                </div>
            </div>

    </div>
</body>
</html>